package main

import (
	"fmt"
	"strconv"
	"time"
)

func main() {
	chanA := make(chan int, 3)
	chanB := make(chan int, 4)
	chanC := make(chan int, 5)
	chanA <- 1
	chanB <- 2
	chanC <- 3

	chanA <- 1
	chanB <- 2
	chanC <- 3

	chanA <- 1
	chanB <- 2
	chanC <- 3

OUTER:
	for {
		select {
		case v := <-chanA:
			fmt.Println("chanA：" + strconv.Itoa(v))
		case v := <-chanB:
			fmt.Println("chanB：" + strconv.Itoa(v))
		case v := <-chanC:
			fmt.Println("chanC：" + strconv.Itoa(v))
		default:
			break OUTER
		}
	}
	fmt.Println("main over")
}

func taskA(chanA chan int) {
	for {
		chanA <- 1
		fmt.Println("taskA")
		time.Sleep(time.Second)
	}
}

func taskB(chanB chan int) {
	for {
		chanB <- 2
		fmt.Println("taskB")
		time.Sleep(time.Second)
	}
}

func taskC(chanC chan int) {
	for {
		chanC <- 3
		fmt.Println("taskC")
		time.Sleep(time.Second)
	}
}
